function Dragger(){
	var me=this;
	this.mousePressed=new Toggle();
	this.dragX=0;
	this.dragY=0;
	this.shiftX=0;
	this.shiftY=0;
	this.dragMode=false;
	this.mousePressed.afterChange=function(){
		if(!me.mousePressed.value()){if(me.dragMode){me.dragMode=false;}}
		else{
			if(!me.dragMode){
				if(me.canvas.value().downX.value()>me._x.value()
						&& me.canvas.value().downY.value()>me._y.value()
						&& me.canvas.value().downX.value()<me._x.value()+me._width.value()
						&& me.canvas.value().downY.value()<me._y.value()+me._height.value()
					){
					me.shiftX=me.canvas.value().shiftX.value();
					me.shiftY=me.canvas.value().shiftY.value();
					me.dragX=me._x.value();
					me.dragY=me._y.value();
					me.dragMode=true;
					}
				}
			}
		};
	this.render=function(context){
		context.fillStyle="rgba(255,0,0,0.1)";
		context.fillRect(this._x.value(),this._y.value(),this._width.value(),this._height.value());
		};		
	this.canvas.afterChange=function(){
		if(me.canvas!=undefined){
			me.mousePressed.bind(me.canvas.value().mousePressed);
			new Amount().bind(me.canvas.value().shiftX).afterChange=function(){
				if(me.dragMode){
					me._x.value(me.dragX+me.canvas.value().shiftX.value()-me.shiftX);
					}
				};
			new Amount().bind(me.canvas.value().shiftY).afterChange=function(){
				if(me.dragMode){
					me._y.value(me.dragY+me.canvas.value().shiftY.value()-me.shiftY);
					}
				};
			}
		};
	this._width=new Amount().value(32);
	this._height=new Amount().value(32);
	this._x=new Amount().value(0);
	this._y=new Amount().value(0);
	this.width=function(n){
		if(n==undefined)return this._width;
		if(n instanceof Amount){
			this._width.bind(n);
			return this;
			}
		this._width.value(n);
		return this;
		};
	this.height=function(n){
		if(n==undefined)return this._height;
		if(n instanceof Amount){
			this._height.bind(n);
			return this;
			}
		this._height.value(n);
		return this;
		};
	this.x=function(n){
		if(n==undefined)return this._x;
		if(n instanceof Amount){
			this._x.bind(n);
			return this;
			}
		this._x.value(n);
		return this;
		};
	this.y=function(n){
		if(n==undefined)return this._y;
		if(n instanceof Amount){
			this._y.bind(n);
			return this;
			}
		this._y.value(n);
		return this;
		};
	}
Dragger.prototype=new Layer();